package com.zbl.zblproject.erp.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zbl.zblproject.core.entity.Supplier;
import com.zbl.zblproject.core.utils.NumberUtil;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/11
 * 零时订单Item
 */
public class ErpTempOrderItem  extends BaseRowModel implements Cloneable{


    private int index;

    /**
     * orderSn
     */
    private String orderSn;

    /**
     * 产品ID
     */
    private int goodsId;

    /**
     * 产品数量
     */
    @ExcelProperty(value = "订购数量", index = 3)
    private int goodsNum;

    /**
     * 产品价格
     */
    @ExcelProperty(value = "单价", index = 4)
    private BigDecimal goodsPrice;
    /**
     * 欠货时间
     */
    private LocalDateTime oweTime;

    private int isTh;

    @Override
    public String toString() {
        return "ErpTempOrderItem{" +
                "index=" + index +
                ", orderSn='" + orderSn + '\'' +
                ", goodsId=" + goodsId +
                ", goodsNum=" + goodsNum +
                ", goodsPrice=" + goodsPrice +
                ", oweTime=" + oweTime +
                ", isTh=" + isTh +
                ", goodsAllPrice=" + goodsAllPrice +
                ", goodsName='" + goodsName + '\'' +
                ", goodsUnit='" + goodsUnit + '\'' +
                ", goodsListName='" + goodsListName + '\'' +
                ", goodsList=" + goodsList +
                ", brandName='" + brandName + '\'' +
                ", centralizedPurchasing=" + centralizedPurchasing +
                ", orderItemId=" + orderItemId +
                ", erpOrderItemId=" + erpOrderItemId +
                ", goodsDesc='" + goodsDesc + '\'' +
                ", specifications='" + specifications + '\'' +
                ", userId=" + userId +
                ", stock=" + stock +
                ", supplier=" + supplier +
                ", supplierId=" + supplierId +
                ", PAddress='" + PAddress + '\'' +
                ", isGive=" + isGive +
                ", oweNum=" + oweNum +
                ", isInto=" + isInto +
                ", logisticsCostRatio=" + logisticsCostRatio +
                ", oweItem=" + oweItem +
                ", numberUnit='" + numberUnit + '\'' +
                ", goodsSn='" + goodsSn + '\'' +
                ", originGoodsNum=" + originGoodsNum +
                ", goodsNumber=" + goodsNumber +
                ", soldNumberOfBeforeMonth=" + soldNumberOfBeforeMonth +
                ", lastTime=" + lastTime +
                ", discount=" + discount +
                ", defaultWarehouse=" + defaultWarehouse +
                ", catName='" + catName + '\'' +
                ", supplierName='" + supplierName + '\'' +
                ", shopPrice=" + shopPrice +
                '}';
    }

    /**
     * 总价
     */
    @ExcelProperty(value = "金额", index = 5)
    private BigDecimal goodsAllPrice;

    /**
     * 产品名称
     */
    @ExcelProperty(value = "商品名称", index = 0)
    private String goodsName;

    /**
     * 产品规格
     */
    @ExcelProperty(value = "规格", index = 1)
    private String goodsUnit;

    /**
     * 货位名称
     */
    private String goodsListName;

    /**
     * 货位ID
     */
    private int goodsList;


    /**
     * 品牌名称
     */
    @ExcelProperty(value = "品牌", index = 2)
    private String brandName;

    /**
     * 是否直供
     */
    private int centralizedPurchasing;


    /**
     * orderItem的ID号
     */
    private int orderItemId;

    private int erpOrderItemId;

    private String goodsDesc;

    private String specifications;

    /**
     * 用户ID
     */
    private int userId;

    /**
     * 产品库存
     */
    private int stock;

    /**
     * 供应商
     */
    private Supplier supplier;

    /**
     * 供应商ID
     */
    private int supplierId;

    /**
     * 生产地
     */
    private String PAddress;


    private int isGive;

    /**
     * 欠缺货数量
     */
    private int oweNum;

    /**
     * 是否导入
     */
    private int isInto;
    /**
     *物流费用比率
     * @return
     */
    private BigDecimal logisticsCostRatio;
    /**
     * 是否欠缺货物
     */
    private int oweItem;

    private String numberUnit;

    private String goodsSn;

    /**
     * 原始订单数量
     */
    private int originGoodsNum;

    /**
     * 所有的库存数量
     */
    private int goodsNumber;

    /**
     * 上个月的销售额度
     */
    private int soldNumberOfBeforeMonth;

    private int lastTime;

    /**
     * 折扣
     */
    private BigDecimal discount;

    @JSONField(serialzeFeatures= SerializerFeature.WriteMapNullValue)
    private ErpWarehouse defaultWarehouse;

    @TableField(exist = false)
    private String catName;

    @TableField(exist = false)
    private String supplierName;

    @TableField(exist = false)
    private BigDecimal shopPrice;
    public int getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(int goodsId) {
        this.goodsId = goodsId;
    }

    public String getOrderSn() {
        return orderSn;
    }

    public void setOrderSn(String orderSn) {
        this.orderSn = orderSn;
    }

    public int getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(int goodsNum) {
        this.goodsNum = goodsNum;
    }

    public BigDecimal getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(BigDecimal goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsUnit() {
        return goodsUnit;
    }

    public void setGoodsUnit(String goodsUnit) {
        this.goodsUnit = goodsUnit;
    }

    public String getGoodsListName() {
        return goodsListName;
    }

    public void setGoodsListName(String goodsListName) {
        this.goodsListName = goodsListName;
    }

    public int getGoodsList() {
        return goodsList;
    }

    public void setGoodsList(int goodsList) {
        this.goodsList = goodsList;
    }

    public int getCentralizedPurchasing() {
        return centralizedPurchasing;
    }

    public void setCentralizedPurchasing(int centralizedPurchasing) {
        this.centralizedPurchasing = centralizedPurchasing;
    }


    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }


    public int getOrderItemId() {
        return orderItemId;
    }

    public void setOrderItemId(int orderItemId) {
        this.orderItemId = orderItemId;
    }

    public String getGoodsDesc() {
        return goodsDesc;
    }

    public void setGoodsDesc(String goodsDesc) {
        this.goodsDesc = goodsDesc;
    }

    public String getSpecifications() {
        return specifications;
    }

    public void setSpecifications(String specifications) {
        this.specifications = specifications;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }


    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public String getPAddress() {
        return PAddress;
    }

    public void setPAddress(String PAddress) {
        this.PAddress = PAddress;
    }


    public int getIsGive() {
        return isGive;
    }

    public void setIsGive(int isGive) {
        this.isGive = isGive;
    }


    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }


    public BigDecimal getGoodsAllPrice() {
        if(goodsPrice == null){
            return BigDecimal.ZERO;
        }
        return goodsPrice.multiply(new BigDecimal(goodsNum));
    }

    public void setGoodsAllPrice(BigDecimal goodsAllPrice) {
        this.goodsAllPrice = goodsAllPrice;
    }

    public int getOweNum() {
        return oweNum;
    }

    public void setOweNum(int oweNumber) {
        this.oweNum = oweNumber;
    }

    public int getIsInto() {
        return isInto;
    }

    public void setIsInto(int isInto) {
        this.isInto = isInto;
    }

    public String getGoodsSn() {
        return goodsSn;
    }

    public void setGoodsSn(String goodsSn) {
        this.goodsSn = goodsSn;
    }

    public String getNumberUnit() {
        if(numberUnit != null) {
            return String.valueOf(NumberUtil.computer(numberUnit));
        }else{
            return "";
        }
    }

    public void setNumberUnit(String numberUnit) {
        this.numberUnit = numberUnit;
    }

    public int getOweItem() {
        return oweItem;
    }

    public void setOweItem(int oweItem) {
        this.oweItem = oweItem;
    }

    public ErpWarehouse getDefaultWarehouse() {
        return defaultWarehouse;
    }

    public void setDefaultWarehouse(ErpWarehouse defaultWarehouse) {
        this.defaultWarehouse = defaultWarehouse;
    }

    public int getOriginGoodsNum() {
        return originGoodsNum;
    }

    public void setOriginGoodsNum(int originGoodsNum) {
        this.originGoodsNum = originGoodsNum;
    }


    public int getGoodsNumber() {
        return goodsNumber;
    }

    public void setGoodsNumber(int goodsNumber) {
        this.goodsNumber = goodsNumber;
    }

    public int getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(int supplierId) {
        this.supplierId = supplierId;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public ErpTempOrderItem cloneNew(){
        try {
            return (ErpTempOrderItem) clone();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ErpTempOrderItem that = (ErpTempOrderItem) o;
        return goodsId == that.goodsId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(goodsId);
    }


    public int getSoldNumberOfBeforeMonth() {
        return soldNumberOfBeforeMonth;
    }

    public void setSoldNumberOfBeforeMonth(int soldNumberOfBeforeMonth) {
        this.soldNumberOfBeforeMonth = soldNumberOfBeforeMonth;
    }

    public int getLastTime() {
        return lastTime;
    }

    public void setLastTime(int lastTime) {
        this.lastTime = lastTime;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

    public LocalDateTime getOweTime() {
        return oweTime;
    }

    public void setOweTime(LocalDateTime oweTime) {
        this.oweTime = oweTime;
    }

    public int getErpOrderItemId() {
        return erpOrderItemId;
    }

    public void setErpOrderItemId(int erpOrderItemId) {
        this.erpOrderItemId = erpOrderItemId;
    }

    public int getIsTh() {
        return isTh;
    }

    public void setIsTh(int isTh) {
        this.isTh = isTh;
    }

    public BigDecimal getLogisticsCostRatio() {
        return logisticsCostRatio;
    }

    public void setLogisticsCostRatio(BigDecimal logisticsCostRatio) {
        this.logisticsCostRatio = logisticsCostRatio;
    }

    public String getCatName() {
        return catName;
    }

    public void setCatName(String catName) {
        this.catName = catName;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public BigDecimal getShopPrice() {
        return shopPrice;
    }

    public void setShopPrice(BigDecimal shopPrice) {
        this.shopPrice = shopPrice;
    }
}
